#include <iostream>
#include <vector>
#include "BinaryTree.h"

struct Node
{
    int label;
    Node* left;
    Node* right;

    ~Node() {
      delete left;
      delete right;
      }
};


void BST_sort(Node* &tree, int x)       
{
    if(!tree){
        tree = new Node;
        tree->label = x;
        tree->right = NULL;
        tree->left = NULL;
        return;
    }
    if(x < tree->label) BST_sort(tree->left, x);
    if(x > tree->label) BST_sort(tree->right, x);
    return;
}

void insertArrayTree(int arr[], int n, Node* &tree)    
{
    for(int i=0; i<n; i++){
        BST_sort(tree, arr[i]);
    }
    return;
}

int insertIntoArray(int arr[], Node* &tree, int i)    
{
    if(!tree) return i;
    i = insertIntoArray(arr, tree->left, i);
    arr[i] = tree->label;
    i++;
    i = insertIntoArray(arr, tree->right, i);
    return i;

}

int main()
{
    int num
    Node* maintree;
    maintree = NULL;
    int num = 7;
    int arr[num] = {120, 30, 115, 40, 50, 100, 70};
    insertArrayTree(arr, num, maintree);     
    insertIntoArray(arr, maintree, 0);        

    for(int y=0; y<num; y++) cout<< arr[y] << ' ';

    return 0;
}

	return 0;

int main()
{
	vector<int> a = {8,12,2,3,4,5,6};

	Randomize_BST_Sort(a);

	cout << "Sorted" << endl;
	for (vector<int>::iterator it = a.begin(); it != a.end(); ++it)
	{
		cout << *it << endl;
	}

	cin.get();

	return 0;
}